home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
1116.ZIP
/
TOOLKIT.ARC
/
_FILES.C
next >
Wrap
Text File
|
1979-12-31
|
1KB
|
38 lines
/* _FILES.C
This Small C program demonstrates fprintf().
Note: HEXPRINT.C demonstrates hexprint()
which is also a function found in _FILES.H
*/
#include _files.h
main()
{
int *fout,nout;
fout = fopen("_FILES.DAT","W");
putc(13,fout);
putchar(13);
puts("Enter a number from 0 to 9: "); nout = getchar(nout);
putchar(13); putchar(13);
if((nout<48)|(nout>57))
{ puts("error, 0-9 only"); fclose(fout); exit(); }
nout = nout - 48;
fprintf("A number is written to this file by _FILES.C\n\n",0,fout);
putc(13,fout);
fprintf("In decimal, the number is: ",0,fout);
fprintf("%d",nout,fout); putc(13,fout);
fprintf("In hexadecimal, the number is: ",0,fout);
fprintf("%h",nout,fout); putc(13,fout);
fprintf("In octal, the number is: ",0,fout);
fprintf("%o",nout,fout); putc(13,fout);
fprintf("In binary, the number is: ",0,fout);
fprintf("%b",nout,fout); putc(13,fout);
puts("Look at the new ASCII file _FILES.DAT to see the result.");
putchar(13); putchar(13);
fclose(fout);
}